package Bai02;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class Threading extends Thread{
	Socket con;
	public Threading(Socket c){
		con=c;
		start();
	}
	public void run(){
		InputStream is;
		FileOutputStream fs;
		byte[] buff=new byte[1024];
		try {
			while(true){
				fs=new FileOutputStream("log.txt",true);
				is=con.getInputStream();
				int i=is.available();
				if(i!=0){
					is.read(buff, 0, i);
					fs.write(buff,0,i);
					fs.write(0x0d);
					fs.write(0x0a);
					//fs.write();
					//System.out.print(new String(buff,0,i));
					
				}
				fs.close();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
